package com.sdutcm.Service.ServiceImpl;

/*
 *@Author Yan
 *@Create 2019-08-21 15:02
 */

import com.sdutcm.Domain.ClassRoom;
import com.sdutcm.Mapper.ClassMapper;
import com.sdutcm.Service.ClassService;
import com.sdutcm.Util.ClassTransform;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private ClassTransform classTransform;
    @Autowired
    private ClassMapper classMapper;

    @Override
    public List<String> classfind(ClassRoom classRoom) throws Exception {
        if (classRoom.getWeek() < 10){
            String session = classTransform.Session(classRoom.getSession());
            String weekday = classTransform.Weekday(classRoom.getWeekday());
            Integer week  = classRoom.getWeek();
            String danshuang = ((week%2 == 0)?"双":"单");
            return classMapper.classfindmin(classRoom.getWeek(),weekday,session,danshuang);

        }else {
            String session = classTransform.Session(classRoom.getSession());
            String weekday = classTransform.Weekday(classRoom.getWeekday());
            Integer week  = classRoom.getWeek() - 10;
            String danshuang = ((week%2 == 0)?"双":"单");
            return classMapper.classfindmax(week,weekday,session,danshuang);
        }
    }
}
